package com.whfc.hdc.service;

import com.whfc.common.exception.BizException;
import com.whfc.common.result.PageData;
import com.whfc.hdc.dto.AppDeviceUpgradeDTO;
import com.whfc.hdc.dto.AppDeviceUpgradePackageDTO;
import com.whfc.hdc.dto.DeviceUpgradeDTO;

import java.util.List;

/**
 * @Description: 硬件升级服务
 * @author: xugcheng
 * @version: 1.0
 * @date: 2019/8/23 15:07
 */
public interface AppDeviceOtaService {

    /**
     * 升级包列表
     *
     * @param deviceType
     * @param pageNum
     * @param pageSize
     * @return
     * @throws BizException
     */
    PageData<AppDeviceUpgradePackageDTO> upgradePackageList(Integer deviceType, Integer pageNum, Integer pageSize) throws BizException;

    /**
     * 添加升级包
     *
     * @param dto
     * @throws BizException
     */
    void addUpgradePackage(AppDeviceUpgradePackageDTO dto) throws BizException;

    /**
     * 删除升级包
     *
     * @param packageId
     * @throws BizException
     */
    void delUpgradePackage(Integer packageId) throws BizException;

    /**
     * 查询硬件升级记录列表
     *
     * @param pageNum
     * @param pageSize
     * @param packageId
     * @param state
     * @param keyword
     * @return
     * @throws BizException
     */
    PageData<AppDeviceUpgradeDTO> upgradeDeviceList(Integer pageNum, Integer pageSize, Integer packageId, Integer state, String keyword) throws BizException;

    /**
     * 查询硬件升级列表
     *
     * @param packageId
     * @return
     */
    List<AppDeviceUpgradeDTO> upgradeDeviceList(Integer packageId);

    /**
     * 添加硬件升级记录
     *
     * @param packageId
     * @param deviceIdList
     * @throws BizException
     */
    void addUpgradeDevice(Integer packageId, List<Integer> deviceIdList) throws BizException;

    /**
     * 删除硬件升级记录
     *
     * @param upgradeId
     * @throws BizException
     */
    void delUpgradeDevice(Integer upgradeId) throws BizException;

    /**
     * 更新硬件升级进度
     *
     * @param deviceId
     * @param masterOrSlave
     * @param newVer
     * @param finish
     * @param total
     * @throws BizException
     */
    void updateUpgradeProgress(Integer deviceId, Integer masterOrSlave, String newVer, Integer finish, Integer total) throws BizException;

    /**
     * 设置硬件升级完毕
     *
     * @param deviceId
     * @throws BizException
     */
    void upgradeComplete(Integer deviceId) throws BizException;

    /**
     * 获取设备的升级策略
     *
     * @param deviceType 硬件类型
     * @param deviceId   硬件ID
     * @param masterVer  主机版本号
     * @param slaveVer   从机版本号
     * @return
     * @throws BizException
     */
    DeviceUpgradeDTO getDeviceUpgrade(Integer deviceType, Integer deviceId, String masterVer, String slaveVer) throws BizException;

    /**
     * 重新加载升级花缓存
     *
     * @throws BizException
     */
    void reloadUpgradeCache() throws BizException;
}
